package com.tw101.module1;

public class FizzBuzz {
    public static String FizzBuzz(int max) {
        StringBuilder outputBuilder = new StringBuilder();

        for(int i = 1; i <= max; i++) {
            if(i != 1) {
                outputBuilder.append("\n");
            }

            if(i % 3 == 0 && i % 5 == 0) {
                outputBuilder.append("FizzBuzz");
            }
            else if(i % 3 == 0) {
                outputBuilder.append("Fizz");
            }
            else if(i % 5 == 0) {
                outputBuilder.append("Buzz");
            }
            else {
                outputBuilder.append(i);
            }
        }
        return outputBuilder.toString();
    }
}
